package com.joyintech.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.joyintech.feign.LimitmanageService;
import com.joyintech.util.ResponseData;
import com.joyintech.util.Verify;
import com.joyintech.util.ZhfxCode;
import com.joyintech.vo.*;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Log4j2
@RestController
@RequestMapping("/limitmanage")
public class LimitController {


    @Autowired
    private LimitmanageService limitmanageService;

//    @PostMapping(value = "/managementSelectById", produces = "application/json;charset=UTF-8")
//    @ResponseBody
//    public String managementSelectById(@RequestBody String message) throws Exception {
//        String decMessage = Verify.decMessage(message);
//
//        String result = limitmanageService.managementSelectById(decMessage);
//        log.info("{}", JSON.toJSONString(result));
//        JSONObject jsonObject = JSON.parseObject(result);
//        String response = Verify.encMessage(jsonObject.toJSONString());
//        return response;
//    }

    @PostMapping(value = "/selectPortfolioManagement", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String selectPortfolioManagement(@RequestBody String message) throws Exception {
        String decMessage = Verify.decMessage(message);
        PortfolioManagementNewVo vo = JSON.parseObject(decMessage, PortfolioManagementNewVo.class);

        String result = limitmanageService.selectPortfolioManagement(vo);
        log.info("{}", JSON.toJSONString(result));
        JSONObject jsonObject = JSON.parseObject(result);
        String response = Verify.encMessage(jsonObject.toJSONString());
        return response;
    }

    @PostMapping(value = "/astPlanSelectById", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String astPlanSelectById(@RequestBody String message) throws Exception {
        String decMessage = Verify.decMessage(message);

        String result = limitmanageService.astPlanSelectById(decMessage);
        log.info("{}", JSON.toJSONString(result));
        JSONObject jsonObject = JSON.parseObject(result);
        String response = Verify.encMessage(jsonObject.toJSONString());
        return response;
    }

    @PostMapping(value = "/astPlanSaveAll", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String astPlanSaveAll(@RequestBody String message) throws Exception {
        String decMessage = Verify.decMessage(message);
        DwdAstPlanManagementVo vo = JSON.parseObject(decMessage, DwdAstPlanManagementVo.class);

        String result = limitmanageService.astPlanSaveAll(vo);
        log.info("{}", JSON.toJSONString(result));
        JSONObject jsonObject = JSON.parseObject(result);
        String response = Verify.encMessage(jsonObject.toJSONString());
        return response;
    }

    @PostMapping(value = "/astPlanSelectList", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String astPlanSelectList(@RequestBody String message) throws Exception {
        String decMessage = Verify.decMessage(message);
        DwdAstPlanManagementPageVo vo = JSON.parseObject(decMessage, DwdAstPlanManagementPageVo.class);

        String result = limitmanageService.astPlanSelectList(vo);
        log.info("{}", JSON.toJSONString(result));
        JSONObject jsonObject = JSON.parseObject(result);
        String response = Verify.encMessage(jsonObject.toJSONString());
        return response;
    }


}
